package com.tong.lib.mvp;

import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tong.lib.base.BaseFragment;
import com.tong.lib.utils.TUtil;

public abstract class BaseMvpFragment<P extends BasePresenter> extends BaseFragment implements IBaseView{

    private P mPresenter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mPresenter = TUtil.getT(this,0);
        mPresenter.attachView(this);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    protected P getP() {
        return mPresenter;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mPresenter.detachView();
    }
}
